output = open("第二周_第二节.py", "w", encoding="utf-8")
content = """
# 1、练习字符串的编码和解码
# 编码(encode)：字节序列（bytes）->字符序列（string）
"你好".encode("utf-8")
# 解码（decode）: 字符序列（string）->字节序列（bytes）
b = "你好".encode("utf-8")
b.decode("utf-8")

#2、练习字符串的CRUD
# Create（创建）
a = "one"
b = "_two"
print(a + b)

a += " two"
print(a)
#Retrieve（检索）
a = "hello, world"
print(a[1])
print(a.find('e'))
print(a.index('e'))

f = "2020-12-27-xxxx"
print(f.startswith("2020-12-27") )

f = xxxx.jpg
print(f.endswith("jpg"))

#Update（更新）
#replace（替换）
a = "oolloo"
print( a.replace("l", "o"))
#split（分割）
a="one, two, three"
print(a.split(","))
#join（拼接）
b = a.split(",")
print(",".join(b))

#Delete（删除）
a = "oolloo"
print(a.strip("o"))
print(a.lstrip("o"))
print(a.rstrip("o"))

#3、练习字符串的格式化
#按传入参数默认顺序
a = "ping"
b = "pong"
print("play pingpong: {}, {}".format(a, b))
#按指定参数索引
print("play pingpong: {0}, {1}, {0}, {1}".format(a, b))
#按关键词参数
print("play pingpong: {a}, {b}, {a}, {b}".format(a='ping', b='pong'))
#按变量
print("f.playing pingpong: {a},{b}")
"""
output.write(content)
output.close()
